# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=spdx-licenses
pkgver=3.22
pkgrel=0
pkgdesc="Various data formats for the SPDX License List"
url="https://spdx.org/"
arch="noarch"
options="!check" # no test suite
license="CC-BY-3.0"
source="license-list-data-$pkgver.tar.gz::https://github.com/spdx/license-list-data/archive/v$pkgver.tar.gz"
builddir="$srcdir/license-list-data-$pkgver"
subpackages="$pkgname-list"

_types="html json rdfa rdfnt rdfturtle rdfxml template text"

for type in $_types; do
	subpackages="$subpackages $pkgname-$type:_subpkg"
done

package() {
	mkdir -p "$pkgdir"
}

_subpkg() {
	local type=${subpkgname/$pkgname-/}
	pkgdesc="$pkgdesc ($type)"
	install_if="$pkgname"
	mkdir -p "$subpkgdir"/usr/share/spdx
	cp -r "$builddir"/$type "$subpkgdir"/usr/share/spdx/
}

list() {
	pkgdesc="$pkgdesc (licence list)"
	mkdir -p "$subpkgdir"/usr/share/spdx
	local i; for i in "$builddir"/text/*.txt; do
		local license=${i##*/}
		echo ${license%.*} >> "$subpkgdir"/usr/share/spdx/license.lst
	done
}

sha512sums="
b213fe66699770d75a4c994a01a5c08325751423516c2fb871088a47e7e7ce605736064f5ce3a63dc1d3c462271832db7bc464ac968df1888f9823787964c786  license-list-data-3.22.tar.gz
"
